package swingSupport.simpleGui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JComponent;

public class MyGraph extends JComponent {
    // This method is called whenever the contents needs to be painted

    @Override
    public void paint(Graphics g) {
        // Retrieve the graphics context; this object is used to paint shapes
        Graphics2D g2d = (Graphics2D) g;

        // Draw an oval that fills the window
        int x = 0;
        int y = 0;
        int width = 100;
        int height = 100;
        g2d.drawOval(x, y, width, height);

        g2d.drawString("(20,20)", 20, 20);
        g2d.drawString("(200,100)", 200, 100);
        g2d.drawString("(100,200)", 100, 200);

        g2d.drawLine(20, 20, 100, 200);
        g2d.drawLine(20, 20, 200, 100);
        g2d.drawLine(100, 200, 200, 100);
        
        g2d.setBackground(Color.ORANGE);
    }

    public MyGraph() {
        //setBorder(BorderFactory.createLineBorder(Color.BLUE));
    }

    @Override
    public Dimension getPreferredSize() {
        return new Dimension(400, 300);
    }
}
